﻿using System;
using System.Globalization;
using Avalonia.Data.Converters;
using Day.Data;

namespace MemorialDay.App.Converters;

public class DateConverter : IValueConverter
{
    public object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
    {
        if (value is not string s) return value;
        var date = s.StringToDateTime();
        return (DateTime.Today - date).Days+"天";
    }

    public object? ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture)
    {
        return value;
    }
}